import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';

class ComAppView extends StatefulWidget {
  const ComAppView({super.key});

  @override
  State<ComAppView> createState() => _ComAppViewState();
}

class _ComAppViewState extends State<ComAppView> {
  @override
  Widget build(BuildContext context) {
    return InAppWebView(
      initialUrlRequest: URLRequest(
        url: WebUri(
          "https://ygk.deman.cn/#/fullscreen/preview1?id=15&stationCode=ZF20230421001&customerId=2386",
        ),
      ),
      initialSettings: InAppWebViewSettings(),
      onLoadStop: (controller, url) async {
        // 设置 localStorage 值
        await controller.evaluateJavascript(
          source: 'localStorage.setItem("key", "value");',
        );
        // 获取 localStorage 值
        final value = await controller.evaluateJavascript(
          source: 'localStorage.getItem("key");',
        );
        print(value);
      },
    );
  }
}
